#!/bin/bash
# jiyin@redhat.com

errataRpcServ="http://errata-xmlrpc.devel.redhat.com/errata/errata_service"
method=get_base_packages_rhts
errata_method_list="get_base_packages_rhts
getErrataBrewBuilds
confirmPackage
cpe_for_channel
getBugsForErrata
getErrataCompletedByLogin
getErrataPackages
getErrataPackagesRHTS
getErrataStats
getErrataStatsByGroup
getErrataStatsByType
getErrataSummary
getRHNChannels
getRequestsByStatus
get_advisory_cdn_file_list
get_advisory_list
get_advisory_rhn_file_list
get_advisory_rhn_metadata
get_cve_info
get_errata_text
get_ftp_paths
get_live_cpe
get_push_info
isAdvisoryFastrack
is_mailed
list_cve_errata
ping
rhsa_map_cpe
set_mailed_flag
updateWebQA"

[ $# -lt 1 ] && {
	echo "Usage: $0 <errataName> [method|?]" >&2
	exit 1
}

errata=$1
[ -n "$2" ] && method=$2
echo "$errata_method_list" | grep -qw "$method" || {
	echo -e "{error} Invalid method '$method', available method list:\n$errata_method_list" >&2
	exit 1
}
echo "{DEBUG} rpccall ${method}(string:$errata)" >&2
xmlrpc-client.sh -t "$errataRpcServ" "${method}" "string:$errata"

